import type { ILoginForm } from '@/api/common'
import { CommonApi } from '@/api/common'
import { useAuthorization } from '@/composables/app'

export const useAppStore = defineStore('app', () => {
  const userInfo = ref({})
  const token = useAuthorization()

  const login = async (data: ILoginForm) => {
    console.log('login', data)
    CommonApi.login(data)
  }

  const logout = () => {
    console.log('logout')
    token.value = ''
  }

  return {
    userInfo,

    login,
    logout,
  }
}, { persist: { key: '__APP_STORE__' } })
